package com.xiaolin.shiro.handler;

import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName MyExceptionHandler
 * @Description 统一异常处理
 * @Detail 统一异常处理
 * @Author MyPC
 * @Date 2020/10/11
 * @Version 1.0
 */
@ControllerAdvice
@Slf4j
public class MyExceptionHandler {

    /**
     * 捕获授权相关的异常
     * @param e
     * @return
     */
    @ExceptionHandler
    @ResponseBody
    public String exceptionHandle(AuthorizationException e){
        log.error("没有权限");
        return "权限不足";
    }
}
